package com.bondqin.sakila.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.bondqin.sakila.entity.Category;

@Repository
public interface CategoryDao extends JpaRepository<Category, Integer>, JpaSpecificationExecutor<Category> {

	@Query(value="select sum(a.amount) from Payment a join a.rental b join b.inventory c join c.film d join d.categories e where e.categoryId = ?1")
	public Double queryTotalSales(Integer categoryId);
	
}
